package com.saicmotor.databinding;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import android.graphics.drawable.Drawable;
import android.os.Bundle;

import com.saicmotor.databinding.bean.User;
import com.saicmotor.databinding.databinding.ActivityMainBinding;
import com.saicmotor.databinding.handler.MyHandler;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {
    ActivityMainBinding binding;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding= DataBindingUtil.setContentView(this,R.layout.activity_main);
        binding.setName("zz");
        binding.setAge(50);
        binding.setIsShow(true);
        // 图片
        Drawable drawable=getResources().getDrawable(R.drawable.shutiao);
        binding.setImage(drawable);
        // 对象
        binding.setUser(new User("yy",22));
        // 集合
        String arrays []={"1","2","3"};
        ArrayList<String> list=new ArrayList();
        list.add("4");
        list.add("5");
        list.add("6");
        binding.setList(list);
        binding.setIndex(1);

        // 点击事件、长按事件
        binding.setHandler(new MyHandler(this));

    }
}